import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import { defineConfig } from 'vite'
// const target = 'https://www.hterobot.com'
// const target = 'https://oj.hterobot.com/api'
const target = 'http://127.0.0.1:7001'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  base: process.env.NODE_ENV === 'production' ?
    'https://cdn.hterobot.com/vue/' : '/',
  build: {
    rollupOptions: {
      input: {
        'index': resolve(__dirname, 'public/index.html'),
        'home': resolve(__dirname, 'public/home.html'),
        'stemHome': resolve(__dirname, 'public/stemHome.html'),
        'bjscyunketang': resolve(__dirname, 'public/bjscyunketang.html'),
        'stcyunketang': resolve(__dirname, 'public/stcyunketang.html'),
        // 码客行
        'acCoderYkt': resolve(__dirname, 'public/acCoderYkt.html'),
      },
    },
    sourcemap: process.env.NODE_ENV === 'production' ? false : 'inline'
  },
  server: {
    host: true,
    proxy: {
      "/api": {
        target,
        changeOrigin: true,
        rewrite: (path: string) => path.replace(/^\/api/, '')
      },
    }
  }
})
